package com.gaswell.canal.chain;

import com.gaswell.canal.Canalinterface;
import com.gaswell.pojo.Diagnosis;
import com.gaswell.utils.RedisEnumeration;
import com.gaswell.utils.SpringUtils;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import java.util.Set;

/**
 * @ClassName Qba01Cleaner
 * @Author xiaow
 * @DATE 2024/6/6 17:02
 **/
public class Qba01Cleaner extends Handler {

    RedisTemplate redisTemplate;

    @Override
    public void handleRequest(Object object) {
        if (redisTemplate == null)
            SpringUtils.getBean("redisTemplate");
        String name = object.getClass().getName();
        String[] split = name.split("\\.");
//      获取类名
        String className = split[split.length - 1];

        if (className.equals("Qba01")) {
            Set keys = redisTemplate.keys(RedisEnumeration.QBA01INSPECTION + "*");
            redisTemplate.delete(keys);
        }


        if (this.successor != null)
            this.successor.handleRequest(object);
    }
}
